home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DTS_Format.h
-
-
-
-
-
- Unfortunately, no matter how long awaited, it's still not done. In fact, this
- isn't even a release- this is just an image of the code taken in the middle of
- development.
-
- THIS CODE DOES NOT WORK AS A WHOLE. MUCH OF IT IS BUGGY AND / OR INCOMPLETE.
- YOU WOULD HAVE TO BE ABSOLUTELY INSANE TO USE ANY OF THIS CODE IN YOUR
- PROJECT WITHOUT EXTENSIVE THOUGHT, DEBUGGING AND TESTING.
-
-
-
-
-
-
- Contains: global types, constants, and function prototypes
-
- Written by: Kent Sandvik
-
- Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- 07/21/92 ckd added define for SCSICmd_ReadCap
- 04/24/92 ckd added structs used by PartitionCurrentDevice()
- 04/21/92 khs added changes from code review
- 03/14/92 BJS changed header, added to project
- 10/19/91 khs first version
-
- To Do:
- */
-
- #ifndef _DTS_FORMAT_
- #define _DTS_FORMAT_
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __SCSI__
- #include <SCSI.h>
- #endif
-
- #ifndef __DTS_SCSI_IO__
- #include <DTS_SCSI_IO.h>
- #endif
-
- // Error values *** need better values for some of these!
- #define kNoOtherValidDrives (-1)
-
- // An invalid SCSI id.
- // *** I wanted this to be "const SCSIAddress kInvalidDevice = -1;" but the compiler choked.
- #define kInvalidDevice (-1)
- #define kPartitionTooSmall (-2)
-
- // Number of blocks we reserve for the driver
- // (Right now it is only a few, but this way we have room to grow)
- #define kDriverSpace 20
-
- // Used to issue a read capacity command to device to find
- // capacity (size) of the disk.
- #define SCSICmd_ReadCap 0x25
-
- // Number of partitions on the drives we format
- // (The driver, the hfs partition, and the partition map itself)
- #define kPartitionCount 3
-
- //
- // Public function prototypes
- // These are called by the formatting routines in DTS_SCSI_Formatter.c
- //
-
- //
- // Get the ID of the current device; return kInvalidDevice if
- // we haven't found a suitable device.
- // *** eventually, get the volume name if it has one!
- //
- extern SCSIAddress CurrentDevice();
-
- //
- // Set the three strings used to identify one of our devices.
- //
- extern void SetValidationInfo(Str255 vendorString, Str255 productString, Str255 revisionString);
-
- //
- // Is this device run by no driver, someone else's driver, a current
- // version of our driver, or an old version of our driver?
- //
- typedef enum TDriverKind { kNoDriver, kDifferentDriver,
- kOurCurrentDriver, kOurOldDriver} TDriverKind;
- extern TDriverKind DriverKind(SCSIAddress device);
-
- //
- // Get the volume reference number and name of the volume mounted on this
- // SCSI device (if any). Assumes that we've already checked to see that
- // this device has some version of our driver controlling it.
- //
- // Return 0 if no volume mounted.
- //
- extern short VolumeFromDevice(SCSIAddress device, Str255 name);
-
- //
- // Find the next eligible device in the chain, and note its SCSI ID in gCurrentDevice.
- // Return 0 if we found a different one than the current one, or:
- // kNoOtherValidDrives: if the only drive we could find is the current one.
- // *** some low-level error: if we couldn't find any valid drives, or if we
- // couldn't communicate over the bus at all.
- //
- extern OSErr NextEligibleDevice();
-
- //
- // Format the current SCSI device.
- // This routine assumes that the current device is one of our devices, and that it's OK with
- // the user that we trash it. The caller should put up whatever message is appropriate
- // ("Formatting…") before calling this routine.
- //
- extern OSErr FormatCurrentDevice();
-
-
- // Format a particular SCSI device. This routine could be used to define a special
- // SCSI address and format the existing driver at this address. FormatCurrentDevice
- // is calling this lower level routine
-
- extern OSErr FormatSCSIDevice(SCSIAddress device);
-
- // Test the current SCSI device.
- // This routine assumes that the current device is one of our devices. The caller should
- // put up whatever message is appropriate ("Testing…") before calling this routine. This
- // routine will put up and spin a busy cursor (*** eventually).
-
- extern OSErr TestCurrentDevice();
-
- // Write partitioning information to the current device.
- // Assumes that the device has been successfully formatted.
-
- OSErr PartitionCurrentDevice();
-
- // Install a new driver on top of the old driver on the current device. Assumes
- // the drive has already been formatted and partitioned.
-
- OSErr UpdateCurrentDevice();
-
- //
- // Mount the newly formatted and partitioned device.
- //
- OSErr MountCurrentDevice();
-
- //
- // Unmount the soon-to-be formatted device.
- //
- OSErr UnmountCurrentDevice();
-
- //
- // Check a SCSI device
- //
- OSErr CheckSCSIDevice(SCSIAddress device);
-
- //
- // Do a low level Test Unit Ready call to the SCSI Device
- //
- OSErr SCSITestUnitReady(SCSIAddress device);
-
- //
- // Do a low level INQUIRY call to the SCSI Device
- //
- OSErr SCSIDoInquiryCommand(SCSIAddress device);
-
- //
- // Do a low level READ CAPACITY call to the SCSI Device
- //
- unsigned long SCSIDoReadCapacityCommand(SCSIAddress device);
-
- //
- // Get the volume name of the SCSI device
- //
- Str31 SCSIGetVolumeName();
-
- //
- // Test if the drive is a valid drive for our format/dev driver code
- //
- OSErr SCSIMatchDriveInfo(char* vendor, char* product, char* revision);
-
- #endif _DTS_FORMAT_
-